package com.isunland.managesystem.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BaseButterKnifeAdapter;
import com.isunland.managesystem.base.BaseVolleyActivity;
import com.isunland.managesystem.entity.CustomerProblem;
import com.isunland.managesystem.utils.MyStringUtil;
import com.isunland.managesystem.utils.MyUtils;
import java.util.ArrayList;

/**
 * 对象功能:
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: HuXiaoDan
 * 创建时间: 2017/2/23 09:50
 */
//public class CustomerProblemListAdapter extends BaseShadowListAdapter<CustomerProblem> {
//
//
//    public CustomerProblemListAdapter(Context context, List<CustomerProblem> objects) {
//        super(context, objects);
//    }
//
//    @Override
//    public void bindData(int position, ViewHolder vh, CustomerProblem item) {
////        if ("undeal".equalsIgnoreCase(item.getDataStatus())){
////            vh.mContentStatusTv.setText("未处理");//数据状态
////            vh.mContentStatusTv.setTextColor(getContext().getResources().getColor(R.color.red));
////        }
//        MyUtils.switchShadowStutus(getContext(),vh.mContentStatusTv,item.getDataStatus());//数据状态
//        vh.mContentTwoTv.setText(item.getCustomerName());//客户名称
//        vh.mContentTwoTv.setTextColor(getContext().getResources().getColor(R.color.chocolate));
//        vh.mContentThreeTv.setText(item.getReportDesc());//申报内容
//        vh.mPersonNameTv.setText(item.getRegStaffName());//登记人
//        vh.mPersonDataTv.setText(item.getRegDate());//登记时间
//
//    }
//}

public class CustomerProblemListAdapter extends BaseButterKnifeAdapter<CustomerProblem> {

  private Context context;

  public CustomerProblemListAdapter(BaseVolleyActivity context,
      ArrayList<CustomerProblem> objects) {
    super(context, objects);
    this.context = context;
  }

  @Override protected int setLayoutId() {
    return R.layout.adapter_list_item;
  }

  @NonNull @Override protected BaseViewHolder initHolder(View convertView) {
    return new ViewHolder(convertView);
  }

  @Override protected void initView(CustomerProblem item, BaseViewHolder baseHolder, int position) {
    ViewHolder holder = (ViewHolder) baseHolder;
    MyUtils.switchShadowStutus(context, holder.tvStatus, item.getDataStatus());//数据状态
    holder.tvTitle.setText(item.getCustomerName());//客户名称
    holder.tvContent1.setText(item.getReportDesc());//申报内容
    holder.tvBottomLeft.setText(
        MyStringUtil.connect(item.getRegStaffName(), MyStringUtil.SEPEREATE, item.getRegDate()));
  }

  class ViewHolder extends BaseViewHolder {
    @BindView(R.id.tv_title) TextView tvTitle;
    @BindView(R.id.tv_status) TextView tvStatus;
    @BindView(R.id.tv_content1) TextView tvContent1;
    @BindView(R.id.tv_bottomLeft) TextView tvBottomLeft;
    @BindView(R.id.tv_bottomRight) TextView tvBottomRight;

    ViewHolder(View view) {
      super(view);
      ButterKnife.bind(this, view);
    }
  }
}
